package com.itheima.demo;
import java.util.Scanner;

/**
 * 综合小案例
 * 开发一个简单的健康计算器应用程序，它可以接受用户的输入（如年龄、性别、体重、身高），并计算出用户的BMI（身体质量指数）
 *以及基础代谢率（BMR）
 */
public class lastDemo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户的年龄");
        int age = sc.nextInt();
        System.out.println("请输入用户的性别");
        String gender = sc.next();
        System.out.println("请输入用户的体重（kg）");
        double weight = sc.nextDouble();
        System.out.println("请输入用户的身高（以米为单位）");
        double height = sc.nextDouble();
        System.out.println("用户的BMI指数为：" + calculateBMI(weight,height,gender));
        double BMI = calculateBMI(weight,height,gender);
        if (BMI < 18.5) {
            System.out.println("体重过低");
        }else if (BMI >= 18.5 && BMI <= 24.9) {
            System.out.println("正常体重");
        }else if (BMI >= 25 && BMI <= 29.9) {
            System.out.println("超重");
        }else if (BMI >= 30 && BMI <= 39.9) {
            System.out.println("肥胖");
        }
        calculateBMR(weight,height,age,gender);
        System.out.println("=========================");
    }
    public static double calculateBMI(double weight, double height,String gender){
        double BMI = weight / (height * height * 100);
        return BMI;
    }
    public static double calculateBMR(double weight, double height,int age,String gender){
        double BMR = 0;
        if(gender.equals("boy")){
            BMR = 88.362 + (13.397 * weight) + (4.799 * height * 100) - (5.677 * age);
            System.out.println("用户为男性且BMR为："+ BMR);
        }
        if(gender.equals("girl")){
            BMR = 447.593 + (9.247 * weight) + (3.098 * height * 100) - (4.330 * age);
            System.out.println("用户为女性且BMR为："+ BMR);
        }
        return BMR;
    }
}
